<?php
namespace tjsd\view;

/**
 * View container which only stores data in memory and returns them when asked to.
 * 
 * @author Jakub Tesárek <info@tjsd.cz>
 * @copyright 2012
 * @version 1.0
 */
class SimpleViewContainer extends ViewContainerAdapter {
	
	/**
	 * @var array			contains all assigned values
	 */
	protected $container;

	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key		identifier of item
	 * @return mixed				value stored in container or null if nothing found
	 */
	public function get($key) {
		if(isset($this->container[$key])) {
			return $this->container[$key];
		} else {
			return NULL;
		}
	}
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key		identifier of item
	 * @param string $value		value to be stored
	 */
	public function add($key, $value) {
		$this->container[$key] = $value;
	}
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key			identifier of item
	 */
	public function remove($key) {
		unset($this->container[$key]);
	}
	
	/**
	 * {@inheritdoc}
	 * 
	 * @param string $key			identifier of item
	 * @return bool					true if item was found
	 */
	public function contain($key) {
		return isset($this->container[$key]);
	}
}